#!/usr/bin/ruby
# -*- ruby -*-
#
# http://programmingpraxis.com/2013/02/19/npr-sunday-puzzle/

require 'set'

DICT = "/usr/share/dict/words"

b = Set.new(%w{a b c d e f})

File.open(DICT) do |f|
    f.readlines.each do |w|
        w.strip!

        next unless /^[a-zA-Z]+$/.match(w) and w.size == 8

        ws = Set.new(w.split(//))

        puts w if b.clone.delete_if { |l| ws.include?(l) }.empty?
    end
end
